<?php
$this->breadcrumbs = array(
	'凭证统计报表' => array(
		'stat'
	),
	'资产负债表'
);

?>

<h1>多期统计</h1>
<div class="form">
<?php $form = $this
	->beginWidget('CActiveForm',
		array(
			'action' => Yii::app()->createUrl($this->route),
			'method' => 'get',
		));
?>

<fieldset>
<legend>搜索条件</legend>

	<?php echo $form->errorSummary($viewSOFPModel); ?>
	<div class="row">
		<?php echo $form->labelEx($viewSOFPModel, 'accountTokenProjectId'); ?>
		<?php echo $form
			->dropDownList($viewSOFPModel, 'accountTokenProjectId',
				CHtml::listData(AccountTokenProject::getAll(), 'id', 'name'),
				array(
					'empty' => '所有公司账目'
				));
		?>
		<?php echo $form->error($viewSOFPModel, 'accountTokenProjectId'); ?>
	</div>
	<div class="row">
		<?php echo $form->label($viewSOFPModel, 'startDate'); ?>
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $viewSOFPModel,
					'attribute' => 'startDate',
				));
		?> - 
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $viewSOFPModel,
					'attribute' => 'endDate',
				));
		?>
	</div>
	<div class="row buttons">
		<?php echo CHtml::submitButton('确定'); ?>
	</div>

</fieldset>
<?php $this->endWidget(); ?>
</div>
<?php
if ($viewSOFPModel->validate()) {

?>
<div id="stat-container"></div>
<?php
	$financialDataJson = CJSON::encode($financialData);
	$script = <<<EOF
Ext.onReady(function(){
	Ext.define('JX.Model.Account.Token.SOFPModel', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'name1',     type: 'string'},
            {name: 'previousValue1',     type: 'float'},
            {name: 'currentValue1',     type: 'float'},
            {name: 'name2', type: 'string'},
            {name: 'previousValue2',     type: 'float'},
            {name: 'currentValue2',     type: 'float'}
        ]
    });

    var store = Ext.create('Ext.data.ArrayStore', {
        model: 'JX.Model.Account.Token.SOFPModel',
        data: $financialDataJson
    });

    var tree = Ext.create('Ext.grid.Panel', {
        title: '资产负债表 {$viewSOFPModel->startDate}-{$viewSOFPModel->endDate}',
        width: '100%',
        height: 550,
        renderTo: 'stat-container',
        collapsible: false,
        useArrows: true,
        rootVisible: false,
        store: store,
        multiSelect: false,
        singleExpand: false,
        resizable: 's',
        columns: [{
            text: '条目',
        	align: 'left',
            flex: 2,
            dataIndex: 'name1',
            sortable: false
        },{
        	xtype:'numbercolumn',
        	align: 'right',
            text: '前期额',
            flex: 2,
            dataIndex: 'previousValue1',
            sortable: false
        },{
        	xtype:'numbercolumn',
        	align: 'right',
            text: '本期额',
            flex: 2,
            dataIndex: 'currentValue1',
            sortable: false
        },{
            text: '条目',
        	align: 'left',
            flex: 2,
            dataIndex: 'name2',
            sortable: false
        },{
        	xtype:'numbercolumn',
        	align: 'right',
            text: '前期额',
            flex: 2,
            dataIndex: 'previousValue2',
            sortable: false
        },{
        	xtype:'numbercolumn',
        	align: 'right',
            text: '本期额',
            flex: 2,
            dataIndex: 'currentValue2',
            sortable: false
        }]
    });
});
EOF;
	Yii::app()->clientScript
		->registerScript('account-stat-single', $script, CClientScript::POS_END);
}
?>
